package com.ctgu.fastleader.controller;

import com.ctgu.fastleader.service.InputOrderService;
import com.ctgu.fastleader.vo.InputOrder;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("/inputorder")
public class InputOrderController {


    @Resource
    private InputOrderService inputOrderService;

//    入库单
    @RequestMapping("/addInputorder")
    public String addInputorder(HttpServletRequest request){
        int supid = Integer.parseInt(request.getParameter("supid"));
        int goodsid = Integer.parseInt(request.getParameter("goodsid"));
        int goodsnum = Integer.parseInt(request.getParameter("goodsnum"));
        Double totalprice = Double.parseDouble(request.getParameter("totalprice"));
        int state = 0;

        InputOrder inputOrder = new InputOrder(supid,goodsid,goodsnum,totalprice,state);

        inputOrderService.insertSelective(inputOrder);

        return "forward:/page/toProduct";
    }

//    首页待入库
    @ResponseBody
    @RequestMapping("/selectInputOrderstate")
    public int selectInputOrderstate(){
        return inputOrderService.selectInputOrderstate();
    }
}
